import request from '../../utils/request'


/**
 * 新建购汇记录
 * @param params
 * @returns {Promise.<void>}
 */
export async function create(data) {
    return request(apiPath.imagent + "/api/fxPurchase", {
        method: 'post',
        data
    });
}

/**
 * 修改购汇记录
 * @param params
 * @returns {Promise.<void>}
 */
export async function update(data) {
    return request(apiPath.imagent + "/api/fxPurchase", {
        method: 'put',
        data
    });
}

/**
 * 删除购汇记录
 * @param id
 * @returns {Promise.<void>}
 */
export async function deleteById({id}) {
    return request(apiPath.imagent + "/api/fxPurchase/"+ id, {
        method: 'delete'
    });
}



/**
 * 获取购汇详情
 * @param id
 * @returns {Promise.<void>}
 */
export async function getById({id}) {
    return request(apiPath.imagent + "/api/fxPurchase/"+ id, {
        method: 'get'
    });
}

/**
 * 分页查询购汇记录
 * @param cstId
 * @param page
 * @returns {Promise.<void>}
 */
export async function queryList({status, payeeman, beginAmt, endAmt, payeeaccount, beginTime, endTime, page}) {
    return request(apiPath.imagent + "/api/fxPurchases", {
        method: 'get',
        data: { status, payeeman, beginAmt, endAmt, payeeaccount, beginTime, endTime, page: page.page, size: page.size}
    });
}

/**
 * 购汇审批
 * @param params
 * @returns {Promise.<void>}
 */
export async function approvalPurchase(data) {
    return request(apiPath.imagent + "/api/fxPurchases/" + data.id + "/approval", {
        method: 'POST',
        data
    });
}

/**
 * 购汇审批记录
 * @param params
 * @returns {Promise.<void>}
 */
export async function queryApprovalStatement({ id, page }) {
    return request(apiPath.imagent + "/api/fxPurchases/" + id + "/approval", {
        method: 'get',
        data:{ id, page: page.page, size: page.size}
    });
}

/**
 * 购汇复核
 * @param params
 * @returns {Promise.<void>}
 */
export async function reviewPurchase(data) {
    return request(apiPath.imagent + "/api/fxPurchases/" + data.entityid + "/review", {
        method: 'POST',
        data
    });
}


/**
 * 获取客户余额
 * @param id
 * @returns {Promise.<void>}
 */
export async function getCstAmtById({id}) {
    return request(apiPath.imagent + "/api/customer/"+ id + "/amt", {
        method: 'get'
    });
}